package com.mock.model;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name="address")
public class Address {

	private Long addressId;
	private String addressName1;
	private String addressName2;
	private String addressName3;
	private String postcode;
	
	private Country country;
	private County county;
	private Town town;
	
	@Id
	@GeneratedValue
	@Column(name="addressId")
	public Long getAddressId() {
		return addressId;
	}
	public void setAddressId(Long addressId) {
		this.addressId = addressId;
	}
	@Column(name="addressName1")
	public String getAddressName1() {
		return addressName1;
	}
	public void setAddressName1(String addressName1) {
		this.addressName1 = addressName1;
	}
	@Column(name="addressName2")
	public String getAddressName2() {
		return addressName2;
	}
	public void setAddressName2(String addressName2) {
		this.addressName2 = addressName2;
	}
	@Column(name="addressName3")
	public String getAddressName3() {
		return addressName3;
	}
	public void setAddressName3(String addressName3) {
		this.addressName3 = addressName3;
	}
	@Column(name="postcode")
	public String getPostcode() {
		return postcode;
	}
	public void setPostcode(String postcode) {
		this.postcode = postcode;
	}
	// one country has many address but one address only contain a country
	@ManyToOne(cascade = CascadeType.ALL)
	@JoinColumn(name="countryId")
	public Country getCountry() {
		return country;
	}
	public void setCountry(Country country) {
		this.country = country;
	}
	// one county has many address but one address only contain a county
	@ManyToOne(cascade = CascadeType.ALL)
	@JoinColumn(name="countyId")
	public County getCounty() {
		return county;
	}
	public void setCounty(County county) {
		this.county = county;
	}
	// one town has many address but one address only contain a town
	@ManyToOne(cascade = CascadeType.ALL)
	@JoinColumn(name="townId")
	public Town getTown() {
		return town;
	}
	public void setTown(Town town) {
		this.town = town;
	}
	
	
}
